package com.sservice.web.controller.admin;

import com.sservice.model.vo.ClienteleAccountVo;
import com.sservice.service.service.IClienteleAccountService;
import com.sservice.base.entity.dto.BaseResult;
import com.sservice.base.entity.dto.ListResult;
import com.sservice.base.entity.dto.Pagination;
import com.sservice.model.entity.ClienteleAccount;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/admin/clienteleAccount")
public class ClienteleAccountController {
    @Autowired
    IClienteleAccountService service;
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    /***
     * 余额账户分页查询
     * @param arg
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/query", method = RequestMethod.GET)
    public ListResult<ClienteleAccountVo> query(ClienteleAccountVo arg) {
        List<ClienteleAccountVo> list = service.queryByPage(arg);
        int total = service.queryByCount(arg);
        Pagination page = new Pagination(arg.getPage(), total, arg.getSize());
        ListResult<ClienteleAccountVo> res = new ListResult(true, list);
        res.setPage(page);
        return res;
    }

    /**
     * 获取供应商余额账户
     *
     * @param arg
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/get", method = RequestMethod.GET)
    public BaseResult get(ClienteleAccountVo arg) {
        ClienteleAccount list = service.selectClientAccountByClientele(arg.getClienteleId());
        BaseResult<ClienteleAccount> res = new BaseResult(true, list);
        return res;
    }

}
